Skip to content

Parser: Add timeout to parse_option_T#1795

Merged
marcoroth merged 7 commits into
mainfrom
timeout
Jun 12, 2026
Merged

Parser: Add timeout to parse_option_T#1795
marcoroth merged 7 commits into
mainfrom
timeout

Conversation

@marcoroth

@marcoroth marcoroth commented Jun 12, 2026

Copy link
Copy Markdown
Owner

This pull request adds a new timeout argument to parse_option_T and Herb.parse so that a parse operation is limited in the time the parse operation is allowed to consume. It defaults to 1s (or 1000ms) but can be overwritten by passing the timeout keyword argument to Herb.parse:

Herb.parse(source, timeout: 5)

If the timeout is reached, Herb will add a new TimeoutError to the ParseResult and return the incomplete parse result.

@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown

🌿 Interactive Playground and Documentation Preview

A preview deployment has been built for this pull request. Try out the changes live in the interactive playground:


🌱 Grown from commit 4b2f438


✅ Preview deployment has been cleaned up.

@pkg-pr-new

pkg-pr-new Bot commented Jun 12, 2026

Copy link
Copy Markdown
npx https://pkg.pr.new/@herb-tools/formatter@1795
npx https://pkg.pr.new/@herb-tools/language-server@1795
npx https://pkg.pr.new/@herb-tools/linter@1795

commit: 4b2f438

@marcoroth marcoroth merged commit 0330335 into main Jun 12, 2026
32 checks passed
@marcoroth marcoroth deleted the timeout branch June 12, 2026 16:30
marcoroth added a commit that referenced this pull request Jun 12, 2026
This pull request adds a new `max_errors` argument to `parse_option_T`
and `Herb.parse` so that the parser stops generating errors after the
limit is reached. It defaults to 25 but can be overwritten by passing
the `max_errors` keyword argument to `Herb.parse`:

```ruby
Herb.parse(source, max_errors: 50)
```

Setting `max_errors` to `nil` disables the limit.

This prevents pathological inputs (e.g. thousands of unclosed tags) from
generating thousands of error objects, which wastes memory and produces
output no one will read.

Follow-up to #1795.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant